package leetcode.code0884;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import leetcode.IDebug;

//执行用时：2 ms, 在所有 Java 提交中击败了99.60%的用户
//
//内存消耗：39.8 MB, 在所有 Java 提交中击败了5.06%的用户
//
//通过测试用例：55 / 55
public class Solution implements IDebug {

	public String[] uncommonFromSentences(String s1, String s2) {
		String[] words1 = s1.split(" ");
		String[] words2 = s2.split(" ");
		Map<String, Integer> hash = new HashMap<>();
		for (String word : words1) {
			hash.put(word, hash.getOrDefault(word, 0) + 1);
		}
		for (String word : words2) {
			hash.put(word, hash.getOrDefault(word, 0) + 1);
		}
		List<String> ans = new ArrayList<>();
		for (Map.Entry<String, Integer> entry : hash.entrySet()) {
			if (entry.getValue() == 1) {
				ans.add(entry.getKey());
			}
		}
		return ans.toArray(new String[ans.size()]);
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
